function out=tone(digit)
% tone - generates tone for each digit
%        *=10, 0=11 and #=12

FS=8000;
X=0:1/FS:0.2; % time runs for 0.2s

h1=sin(2*pi*1209*X); % high frequencies
h2=sin(2*pi*1336*X);
h3=sin(2*pi*1477*X);

l1=sin(2*pi*697*X); % low frequencies
l2=sin(2*pi*770*X);
l3=sin(2*pi*852*X);
l4=sin(2*pi*941*X);

lut=zeros(12,1601); % sines are 1601 samples long and there are 12 buttons on the keypad
lut(1,:)=h1+l1; % for each of the buttons the correct sines are added together
lut(2,:)=h2+l1;
lut(3,:)=h3+l1;
lut(4,:)=h1+l2;
lut(5,:)=h2+l2;
lut(6,:)=h3+l2;
lut(7,:)=h1+l3;
lut(8,:)=h2+l3;
lut(9,:)=h3+l3;
lut(10,:)=h1+l4; % 10 = *
lut(11,:)=h2+l4; % 11 = 0
lut(12,:)=h3+l4; % 12 = #

out=lut(digit,:);